#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
商户主结算卡查询服务
商户主结算卡查询功能实现
"""

import json
import logging
from typing import Dict, Any, Optional

from jlpay.services.base_service import BaseService
from jlpay.services.org_service import JlpayOrgService
from jlpay.model.openmerch.query.merch_master_sett_card_query import MerchMasterSettCardQueryRequest, MerchMasterSettCardQueryResponse

# 创建全局logger
logger = logging.getLogger("jlpay.service.query")


class MerchMasterSettCardQueryService(BaseService):
    """商户主结算卡查询服务"""
    
    def __init__(self, config):
        """
        初始化商户主结算卡查询服务
        
        Args:
            config: OrgConfig实例
        """
        super().__init__(config)
        # 创建机构服务实例
        self.org_service = JlpayOrgService.builder().config(config).build()
    
    def get_api_url(self, request_class, api_path=None):
        """
        获取API URL
        
        Args:
            request_class: 请求类
            api_path: 接口路径
            
        Returns:
            完整的API URL
        """
        base_url = self.config.url.rstrip('/')
        return f"{base_url}/open/merch/access/merch-settle-info/query"
    
    def query_merch_master_sett_card(self, request: MerchMasterSettCardQueryRequest) -> MerchMasterSettCardQueryResponse:
        """
        查询商户主结算卡
        
        Args:
            request: MerchMasterSettCardQueryRequest实例
            
        Returns:
            MerchMasterSettCardQueryResponse: 商户主结算卡查询响应结果
        """
        return self.post(request, MerchMasterSettCardQueryResponse) 